FROM private-registry.sohucs.com/domeos-pub/node:10-alpine as builder
#使用官方镜像源
# FROM node:10.15.2-alpine as builder

RUN apk add --no-cache git

WORKDIR /app

# 添加源代码
ADD . /app

RUN node -v && npm -v

# 安装npm模块
## 使用淘宝的npm镜像和node-sass-lib
RUN npm config set sass_binary_site "http://npm.taobao.org/mirrors/node-sass/"
# RUN npm config set registry "http://registry.npm.taobao.org/"

## 安装
RUN npm install

# build dist
RUN npm run build

# 运行阶段
FROM private-registry.sohucs.com/domeos-pub/nginx:1.13.7-alpine as production

RUN rm /usr/share/nginx/html/*
COPY --from=builder /app/dist /usr/share/nginx/html

RUN rm /etc/nginx/conf.d/default.conf

COPY --from=builder /app/deploy /etc/nginx/conf.d

EXPOSE 80

CMD ["nginx", "-g", "daemon off;"]
